{include file="public/layout" /}
<body>
  <link rel="stylesheet" href="__SKIN__/css/page.css" media="all">
   <div class="layui-fluid" id="LAY-component-layer-list">
       {include file="admin/bar" /}
      <div class="layui-card">

        <div class="head-oper">
          <div class="fl">
            {eq name="'Admin@admin_add'|is_check_access" value="1"}
            <a data-url="{:url('Admin/admin_add')}" data-type="admin_add" class="layui-btn mt5 ">新增管理员</a>
            {/eq}
          </div>
          <div class="fr">
            <form action="{:url('Admin/index')}" method="get" onsubmit="layer_loading();">
              <div class="fl mt5" >
                {$searchform.hidden|default=''}
                <div class="layui-input-inline w240">
                    <input type="text" name="keywords" value="{$Request.param.keywords}" class="layui-input" placeholder="搜索相关数据...">
                </div>
              </div>
              <div class="layui-input-inline w50 mt5">
                <button class="layui-btn input-btn-search" type="submit"><i class="layui-icon layui-icon-search"></i></button>
              </div>
            </form>
          </div>
<!--           <div class="fr ">
            {eq name="'Admin@index'|is_check_access" value="1"}
            <a href="javascript:void(0);" class="layui-btn layui-btn-xs layui-disabled"><i class="layui-icon layui-icon-template-1"></i>管理员列表</a>
            {/eq}
            {eq name="'AuthRole@index'|is_check_access" value="1"}
            <a lay-href="{:url('AuthRole/index')}" class="layui-btn layui-btn-xs"><i class="layui-icon layui-icon-template-1"></i>权限组列表</a>
            {/eq}
          </div> -->
        </div>
        <div class="layui-card-body">
          <div class="layui-form layui-border-box layui-table-view house-table" lay-filter="formTest" lay-id="admin-arctype" >
            <div class="layui-table-box">
              <div class="layui-table-body " >
                <table cellspacing="0" cellpadding="0" border="0" class="layui-table layui-form" style="width: 100%" lay-skin="line">
                  <thead >
                    <tr>
                      <th class="w40 tc">
                        <div class="layui-table-cell w40 tc laytable-cell-checkbox">
                          <input type="checkbox" lay-filter="checkAll" class="checkAll" lay-skin="primary">
                          <div class="layui-unselect layui-form-checkbox" lay-skin="primary"> <i class="layui-icon layui-icon-ok"></i></div>
                        </div>
                      </th>
                      <th class="w60 tc">
                        <div class="layui-table-cell w60 tc" ><span>ID</span></div>
                      </th>
                      <th>
                        <div class="layui-table-cell wauto"><span>用户名</span></div>
                      </th>
                      <th class="w150 tc">
                        <div class="layui-table-cell w150 tc"><span>角色</span></div>
                      </th>
                      <th class="w180 tc">
                        <div class="layui-table-cell w180 tc"><span>最后登录时间</span></div>
                      </th>
                      <th class="w150 tc">
                        <div class="layui-table-cell w150 tc"><span>操作</span></div>
                      </th>
                    </tr>
                 </thead>
                 <tbody>
                  {empty name="list"}
                    <tr>
                      <td colspan="8" class="no-data tc">
                         没有符合条件的数据
                      </td>
                    </tr>
                  {else/}
                    {foreach name="list" item="vo" key="k" }
                     <tr>
                        <td>
                           <div class="layui-table-cell w40 tc laytable-cell-checkbox">
                            {if condition="$Think.session.admin_id != $vo.admin_id AND !empty($vo.parent_id)"}
                              <input type="checkbox" name="ids[]" lay-filter="ids" lay-skin="primary" value="{$vo.admin_id}">
                            {else /}
                              <input type="checkbox" disabled lay-skin="primary" value="{$vo.admin_id}">
                            {/if}
                           </div>
                        </td>
                        <td>
                            <div class="layui-table-cell w60 tc">
                                {$vo.admin_id}
                            </div>
                        </td>
                        <td>
                            <div class="layui-table-cell wauto">
                                {eq name="'Admin@admin_edit'|is_check_access" value="1"}
                                <a href="javascript:void(0);" class="eju-event" data-type="admin_edit" data-url="{:url('Admin/admin_edit',array('id'=>$vo['admin_id']))}">{$vo.user_name}</a>
                                {else /}
                                {$vo.user_name}
                                {/eq}
                            </div>
                        </td>
                        <td>
                            <div class="layui-table-cell w150 tc">
                                {$vo.role_name|default='<b>数据出错</b>'}
                            </div>
                        </td>
                        <td>
                            <div class="layui-table-cell w180 tc">
                                {empty name="vo.last_login"}
                                未登录
                                {else /}
                                {$vo.last_login|date='Y-m-d H:i:s',###}
                                {/empty}
                            </div>
                        </td>
                        <td>
                           <div class="layui-table-cell w150 tl right-oper">
                            {eq name="'Admin@admin_edit'|is_check_access" value="1"}
                                <a class="layui-btn btn-edit customvar_edit" data-url="{:url('Admin/admin_edit',array('id'=>$vo['admin_id']))}" data-type="admin_edit">编辑</a>
                            {/eq}
                            {eq name="'Admin@admin_del'|is_check_access" value="1"}
                              {if condition="$Think.session.admin_id != $vo.admin_id AND !empty($vo.parent_id)"}
                                <a class="layui-btn btn-primary" href="javascript:void(0);" data-url="{:url('Admin/admin_del')}" data-id="{$vo.admin_id}" data-type="admin_del">删除</a>
                              {else /}
                                <a class="layui-btn btn-primary" href="javascript:void(0);" style="color:#ccc; cursor:not-allowed">删除</a>
                              {/if}
                            {/eq}
                           </div>
                        </td>
                      </tr>
                    {/foreach}
                  {/empty}
                  </tbody>
                </table>
              </div>
            </div>
            <div class="layui-table-page footer-oper">
                <input type="checkbox" lay-filter="checkAll" class="checkAll" lay-skin="primary" >
                {eq name="'Admin@admin_del'|is_check_access" value="1"}
                <a class="layui-btn layui-btn-primary " data-type="batch_del" data-url="{:url('Admin/admin_del')}" style="line-height: 34px;">
                批量删除
                </a>
                {/eq}
            </div>
            <!--分页-->

          </div>
            {$page}
        </div>
      </div>
 </div>
<input type="hidden" name="head_pic" id="head_pic" value="{$Think.session.admin_info.head_pic}">
  <script>
  layui.config({
    base: '__SKIN__/' //静态资源所在路径
    ,version: '{$version}'
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form'], function(){
    var $ = layui.$
    ,form = layui.form;

    // 上传头像及时显示
    if ('' != $('#head_pic').val()) {
      $('#admin_head_pic', window.parent.document).attr('src', $('#head_pic').val());
    }

    // 监听复选框全选
    form.on('checkbox(checkAll)', function(data){
        if (data.elem.checked) {
            $('.checkAll').attr('checked', true);
            $('input[name*=ids]').attr('checked', true);
        } else {
            $('.checkAll').attr('checked', false);
            $('input[name*=ids]').attr('checked', false);
        }
        form.render('checkbox');
    });

    // 监听每行复选框
    form.on('checkbox(ids)', function(data){
        if (data.elem.checked && $('input[name*=ids]:checked').length == $('input[name*=ids]').length) {
            $('.checkAll').attr('checked', true);
        } else {
            $('.checkAll').attr('checked', false);
        }
        form.render('checkbox');
    });

    /* 触发事件 */
    var active = {
        admin_add: function(){
            var iframes = layer.open({
                type: 2,
                title: '新增管理员',
                fixed: true, //不固定
                shadeClose: false,
                shade: 0.3,
                content: $(this).data('url')
            });
            layer.full(iframes);
        }
        ,admin_edit: function(){
            var iframes = layer.open({
                type: 2,
                title: '编辑管理员',
                fixed: true, //不固定
                shadeClose: false,
                shade: 0.3,
                content: $(this).data('url')
            });
            layer.full(iframes);
        }
        ,admin_del: function(){
            delfun(this);
            return false;
        }
        ,batch_del: function(){
            batch_del(this, 'ids');
            return false;
        }
    };

    $('#LAY-component-layer-list .layui-btn,.eju-event').on('click', function(){
      var type = $(this).data('type');
      active[type] && active[type].call(this);
    });

  });

  </script>
{include file="public/footer" /}